home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / bc_pas_1.zip / PHASE.C < prev    next >
C/C++ Source or Header  |  1992-07-17  |  2KB  |  100 lines

  1.  
  2. ;   /*\
  3. ;---|*|----====< phase >====----
  4. ;---|*|
  5. ;---|*| This program demonstrates the phase effects of throwing the FM
  6. ;---|*| chips frequencies out of phase when playing a note
  7. ;---|*|
  8. ;   \*/
  9.  
  10.  
  11. #include <stdio.h>
  12.  
  13. ;   /*\
  14. ;---|*|----====< main >====----
  15. ;   \*/
  16.  
  17. main()
  18. {
  19.  
  20.     // initialize the FM interface
  21.  
  22.         mvFMInitMode(1);                // 1 = split mode
  23.  
  24.     // Load the FM patch
  25.  
  26.         LoadPatch();
  27.  
  28.     // Play each side of the chip a little differently
  29.  
  30.         dophase (0);
  31.         dophase (1);
  32.         dophase (2);
  33.         dophase (4);
  34.         dophase (8);
  35.         dophase (16);
  36.         dophase (32);
  37.  
  38.     // turn off the audio
  39.  
  40.         outdual3812 (0xB0, 0x00, 0x00);
  41.  
  42.         printf ("\noff...\n");
  43.  
  44. }
  45.  
  46.  
  47. ;   /*\
  48. ;---|*|----====< dophase >====----
  49. ;---|*|
  50. ;---|*| Play each half of the FM chip with an adjusted frequency
  51. ;---|*|
  52. ;    \*/
  53.  
  54. dophase(offst)
  55.     int offst;
  56. {
  57.         if (offst)
  58.             printf ("\nfrequency off center by %d...",offst);
  59.  
  60.         else
  61.             printf ("\nNo phase shifting...");
  62.  
  63.         outdual3812
  64.           (
  65.             0xA0,
  66.             0x6B+offst,
  67.             0x6B-offst
  68.           );
  69.  
  70.         outdual3812 (0xB0, 0x35, 0x35);     // KEY-ON=1, block=5, f(9,10)=01
  71.         outdual3812 (0xB0, 0x15, 0x15);     // KEY-ON=0, block=5, f(9,10)=01
  72.  
  73.         printf ("type any key to continue...");
  74.         getch();
  75. }
  76.  
  77.  
  78. ;   /*\
  79. ;---|*|----====< LoadPatch >====----
  80. ;---|*|
  81. ;---|*| Load the FM chip with a patch
  82. ;---|*|
  83. ;   \*/
  84.  
  85. LoadPatch(offst)
  86.     int offst;
  87. {
  88.  
  89.         outdual3812 (0x20, 0x01, 0x01);     // multiple = 1
  90.  
  91.         outdual3812 (0x40, 0x00, 0x00);     // volume on high
  92.  
  93.         outdual3812 (0x60, 0xF0, 0xF0);     // Attack  = F, Decay = 0
  94.  
  95.         outdual3812 (0x80, 0xF1, 0xF1);     // Sustain = F, Release = 1
  96.  
  97.         outdual3812 (0xC0, 0x11, 0x21);     // Left connect = 11h, right = 21h
  98. }
  99.  
  100.